/*************************************************************************
> File Name: libnet.c
> Author: hzy
> Created Time: 2023-09-27 14:38:08
> Description:
************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libnet.h>

int main(int argc, char const *argv[])
{
    // 初始化
    libnet_t *libnet = libnet_init(LIBNET_LINK, "ens33", NULL);

    // 构建UDP
    char buf[128] = {};
    printf("输入字符\n");
    fflush(stdout);
    scanf("%s", buf);
    int len = strlen(buf) + strlen(buf) % 2;
    libnet_build_udp(9000, 8080, 8 + len, 0, buf, len, libnet, 0);

    // 构建IP
    libnet_build_ipv4(20 + 8 + len,
                      0,
                      0,
                      0,
                      64,
                      17,
                      0,
                      inet_addr("10.7.178.203"),//源IP
                      inet_addr("10.7.178.190"),//目的IP
                      NULL,
                      0,
                      libnet,
                      0);

    //构建MAC
    

    return 0;
}